package com.kgc.ssm.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.kgc.ssm.entity.ContractApply;
import com.kgc.ssm.entity.ContractApplyExample;
import com.kgc.ssm.entity.dto.Result;
import com.kgc.ssm.mapper.ContractApplyMapper;
import com.kgc.ssm.service.ContractApplyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

/**
 * 待审批合同处理service实现类
 */

@Service
@Transactional
public class ContractApplyServiceImpl implements ContractApplyService {

    @Autowired(required = false)
    private ContractApplyMapper contractApplyMapper;

    @Override
    public Result<List<ContractApply>> findPage(Integer pageNum, Integer pageSize) {
        //开始分页
        PageHelper.startPage(pageNum, pageSize);
        //设置条件
        ContractApplyExample example = new ContractApplyExample();
        ContractApplyExample.Criteria criteria = example.createCriteria();
        criteria.andContractApplyStatusEqualTo("S001-20");
        //执行查询
        Page<ContractApply> page = (Page<ContractApply>) contractApplyMapper.selectByExample(example);
        return new Result<>("查询成功", 200, page.getResult(), page.getTotal());
    }

    @Override
    public List<Map<String, Object>> findById(Integer id) {
        return contractApplyMapper.findById(id);
    }

    @Override
    public int updateByPrimaryKeySelective(ContractApply row) {
        return contractApplyMapper.updateByPrimaryKeySelective(row);
    }
}
